/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <cstdio>
#define N 54

using namespace std;
int init[N+1]={0},order[N+1]={0},target[N+1]={0};
char mp[]={'S','H','C','D','J'};
int main_1042_2()
{
    int K;
    scanf("%d",&K);
    for (int i=1; i<=N;++i )
    {
        scanf("%d",&order[i]);
        init[i]=i;
    }
    for (int i=0;i<K ;++i )
    {
        for (int j=1;j<=N ;++j )
        {
            target[order[j]]=init[j];
        }
        for (int k=1;k<=N ;++k )
        {
            init[k]=target[k];
        }
    }
    for (int i=1;i<=53 ;++i )
    {
        printf("%c%d ",mp[(init[i]-1)/13],(init[i]-1)%13+1);
    }
    printf("%c%d",mp[(init[54]-1)/13],(init[54]-1)%13+1);
	return 0;
}
